﻿IF OBJECT_ID('up_Utility_Asset_Distributions_MeterImages_SelectById') IS not NULL
	DROP PROC up_Utility_Asset_Distributions_MeterImages_SelectById

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'up_Utility_Asset_Distributions_MeterImages_SelectById')
	DROP PROCEDURE up_Utility_Asset_Distributions_MeterImages_SelectById
GO

CREATE PROCEDURE [dbo].[up_Utility_Asset_Distributions_MeterImages_SelectById] 
(
	@imageID int
)AS

SELECT 
	Utility_Asset_Meters_ImageId as 'ID',
	inspMeters.Vendor_Distribution_PoleFk as 'PoleID',
	[Filename] as 'FileName'		
FROM 
	tb_Utility_Asset_Meters_Images meterImages
INNER JOIN tb_Utility_Asset_Meters meters
	ON meters.Utility_Asset_MeterId = meterImages.Utility_Asset_MeterFk
INNER JOIN tb_Vendor_Distribution_Meters inspMeters
	ON inspMeters.Utility_Asset_Meters_MeterFk = meters.Utility_Asset_MeterId
WHERE
	Utility_Asset_Meters_ImageId = @imageID



 